package com.echofeng.common.net;

import android.os.Build;

import com.echofeng.common.config.AppConstants;
import com.echofeng.common.utils.AESCBCCrypt;
import com.echofeng.common.utils.AESCBCCrypt2;
import com.echofeng.common.utils.AESECBCrypt;
import com.echofeng.common.utils.LogUtil;
import com.echofeng.common.utils.PreferenceUtils;

import org.json.JSONObject;

import java.security.GeneralSecurityException;
import java.util.Base64;

public class DataManager {
    private static final String CHARACTER = "UTF-8";
    public static void setAuthorization(String token) {
        PreferenceUtils.applyString(AppConstants.Share.AUTHORIZATION, token);
    }

    public static String getAuthorization() {
        return PreferenceUtils.getString(AppConstants.Share.AUTHORIZATION, "");
    }

    public static String singPostBody(JSONObject jsonObject){
        String jsonBody = jsonObject.toString();
        String aesBody = null;
        try {
            aesBody = AESCBCCrypt2.aesEncrypt(jsonBody);
            LogUtil.debug("singPostBody:",aesBody);
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return aesBody;
    }

    public static void exitAccount() {
        PreferenceUtils.clear();
    }
}
